<!DOCTYPE html>
<html lang="en">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
        <title>爱音乐春季运动会</title>
        <link rel="stylesheet" href="./lib/jquery/jquery.mobile-1.4.5.min.css">
        <link rel="stylesheet" href="css/demo.css">
        <script src="./lib/jquery/jquery-1.9.1.min.js"></script>
        <script src="./lib/jquery/jquery.mobile-1.4.5.min.js"></script>
        <script src="tool/share.js"></script>
        <script type="text/javascript" src="js/awardRotate.js"></script>
        <script src="tool/config.js"></script>
        <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_"+SITE_ID+"'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D"+SITE_ID+"' type='text/javascript'%3E%3C/script%3E"));</script>
        <script type="text/javascript">
            var _czc = _czc || [];
            _czc.push(["_setAccount", SITE_ID]);
            $("#cnzz_stat_icon_"+SITE_ID).css({display:"none"});
        </script>
        <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

        <script type="text/javascript">
            $(function (){
                wx.ready(function() {
                    wx.onMenuShareAppMessage({
                        title: "我在爱音乐春季运动会达到"+window.localStorage.getItem("score")+"分，够胆来挑，狗蛋勿点",
                        desc:  window["shareObj"].decstr,
                        link:  window["shareObj"].linkstr,
                        imgUrl:  window["shareObj"].iconstr,
                        trigger: function (res) {
                        },
                        success: function (res) {
                            _czc.push(["_trackEvent","抽奖","分享成功","","",""]);
                        },
                        cancel: function (res) {
                        },
                        fail: function (res) {
                        }
                    });
                    //分享到朋友圈
                    wx.onMenuShareTimeline({
                        title: "我在爱音乐春季运动会达到"+window.localStorage.getItem("score")+"分，够胆来挑，狗蛋勿点",
                        link:  window["shareObj"].linkstr,
                        imgUrl:  window["shareObj"].iconstr,
                        trigger: function (res) {
                        },
                        success: function (res) {
                            _czc.push(["_trackEvent","抽奖","分享成功","","",""]);
                        },
                        cancel: function (res) {
                        },
                        fail: function (res) {
                        }
                    });
                })
                wx.error(function (res) {
                    console.log(res.errMsg);
                });

                var rotateTimeOut = function (){
                    $('#rotate').rotate({
                        angle:0,
                        animateTo:2160,
                        duration:8000,
                        callback:function (){
                            alert('网络超时，请检查您的网络设置！');
                        }
                    });
                };
                var bRotate = false;

                var rotateFn = function (awards, angles, txt, content){
                    bRotate = !bRotate;
                    $('#rotate').stopRotate();
                    $('#rotate').rotate({
                        angle:0,
                        animateTo:angles+1800,
                        duration:8000,
                        callback:function (){
                            if(awards == 3 || awards == 7 || awards == 10 || awards == 12){
                                // alert(txt);
                            }else{
                                window.location.href = './' + txt + '.html?content=' + content + '&level=' + awards;
                            }
                            bRotate = !bRotate;
                        }
                    })
                };

                $('.pointer').click(function (){
                    $.post(API_ROOT+"lottery?debug="+API_DEBUG,function(result){
                        if(result.success){
                            if(result.flag){
                                if(bRotate)return;
                                _czc.push(["_trackEvent","抽奖","抽奖人数","","",""]);
                                var level = result.data.level;
                                switch (level) {
                                    case 1:
                                        _czc.push(["_trackEvent","抽奖结果","爱音乐钻石会员","","",""]);
                                        rotateFn(1, 360, 'zsmember', result.data.content);//爱音乐钻石会员
                                        break;
                                    case 2:
                                        _czc.push(["_trackEvent","抽奖结果","60M天翼流量","","",""]);
                                        rotateFn(2, 324, 'tianyi60m', result.data.content);//60M天翼流量
                                        break;
                                    case 3:
                                        _czc.push(["_trackEvent","抽奖结果","可惜了","","",""]);
                                        rotateFn(3, 306, '可惜了', result.data.content);
                                        break;
                                    case 4:
                                        _czc.push(["_trackEvent","抽奖结果","100元三网话费","","",""]);
                                        rotateFn(4, 634, 'threenetworky', result.data.content);//100元三网话费
                                        break;
                                    case 5:
                                        _czc.push(["_trackEvent","抽奖结果","院线通10元电影抵用券","","",""]);
                                        rotateFn(5, 588, 'yuanxiantong', result.data.content);//院线通10元电影抵用券
                                        break;
                                    case 6:
                                        _czc.push(["_trackEvent","抽奖结果","50元天翼话费","","",""]);
                                        rotateFn(6, 562, 'tianyi50y', result.data.content);//50元天翼话费
                                        break;
                                    case 7:
                                        _czc.push(["_trackEvent","抽奖结果","谢谢参与","","",""]);
                                        rotateFn(7, 539, '谢谢参与', result.data.content);
                                        break;
                                    case 8:
                                        _czc.push(["_trackEvent","抽奖结果","爱音乐免费彩铃","","",""]);
                                        rotateFn(8, 509, 'ringtone', result.data.content);//爱音乐免费彩铃
                                        break;
                                    case 9:
                                        _czc.push(["_trackEvent","抽奖结果","300M三网流量","","",""]);
                                        rotateFn(9, 475, 'threenetworkm', result.data.content);//300M三网流量
                                        break;
                                    case 10:
                                        _czc.push(["_trackEvent","抽奖结果","抱歉没中哦","","",""]);
                                        rotateFn(10, 438, '抱歉没中哦', result.data.content);
                                        break;
                                    case 11:
                                        _czc.push(["_trackEvent","抽奖结果","2元天翼话费","","",""]);
                                        rotateFn(11, 425, 'tianyi2y');//2元天翼话费
                                        break;
                                    case 12:
                                        _czc.push(["_trackEvent","抽奖结果","谢谢参与","","",""]);
                                        rotateFn(12, 381, '谢谢参与', result.data.content);
                                        break;
                                }
                            }else{
                                alert(result.msg);
                            }                            
                        }else{
                            alert(result.msg);
                        }
                    });
                });
            });
            function rnd(n, m){
                return Math.floor(Math.random()*(m-n+1)+n)
            }
            function goToFocus(){
                _czc.push(["_trackEvent","抽奖","关注按钮","","",""]);
                window.location.href = "./focus.html";
            }
            function showShareTrack(){
                _czc.push(["_trackEvent","抽奖","分享按钮","","",""]);
            }
            function openView(){
                $("#myPopup").popup();
                $("#myPopup").popup('open');
            }

            function closeView(){
                $("#myPopup").popup('close');
            }
        </script>
    </head>
<body>

<img src="image/pointerup.png" style="position: fixed;left:91%;z-index: 999;width: 8%;display: none" id="pointerup">
<div data-role="page" style="background-image: url(image/luckypage.png);background-repeat: no-repeat;background-size:cover;">
    <div data-role="main" class="ui-content">
        <a href="#" data-rel="popup" data-position-to="window" style="float: right;" onclick="openView()">抽奖需知</a>
        <div class="turntable-bg">
            <div class="pointer3"><img src="image/pointer3.png" style="width: 100%;height: 100%;"/></div>
            <div class="pointer2"><img src="image/pointer2.png" style="width: 100%;height: 100%;"/></div>
            <div class="pointer"><img src="image/lottry-text.png" alt="pointer" style="width: 100%;height: 100%;" /></div>
            <div class="rotate" ><img id="rotate" src="image/zhuanpan.png" alt="turntable" style="width: 90%;height: 90%;margin-top: 5%;"/></div>
            <div class="lottry_bg"><img src="image/lottry-bg.png"  style="width: 100%;height: 100%;"/></div>
            <div class="pointer4"><img src="image/luckybottom.png" style="width: 100%;height: 100%;"/></div>
        </div>
        <!-- <div style="text-align: center;">
            <p style="background-color: #af877a;line-height: 35px;width: 62%;margin: 0 auto;border-radius: 5px;font-size: 20px;color: #fff;">您还有<font color="red" id="lotteryCount">0</font>次抽奖机会</p>
        </div> -->
        <div class="ui-grid-a" style="margin-top: 24px;">
            <div class="ui-block-a" style="text-align: center;">
                <a href="#" onclick="window.location.href='index.html';"><img src="image/back.png" width="120px" height="50px"></a>
            </div>

            <div class="ui-block-b" style="text-align: center;">
                <a href="#" onclick="showShareTrack();showShare();"><img src="images/share.png" width="120px" height="50px"></a><br>
            </div>
        </div>
    </div>
    <div style="position: absolute;bottom: 0;">
        <img src="image/footer.png" style="width: 100%;">   

        <a href="javascript:void(0);" onclick="goToFocus();" style="display: inline-block;position: absolute;width: 15%;height: 61%;top: 17%;left: 80%;"></a>

    </div>
    <div data-role="popup" id="myPopup" data-overlay-theme="b" data-history="false" style="border-width: thick;border-radius: 34px;border-color: #e5b564;background-color: #ece7d0;word-wrap: break-word;font-size: 15px;">
        <a href="#" style="padding: 0;position: absolute;top:6px;float: right;right: 13px;" onclick="closeView()"><img src="./image/close.png" style="width: 46px;"></a>
        <span style="display: inline-block;padding:2px;">
            <p style="text-align: center;color: red;font-size: 25px;line-height: 15px;">抽奖需知</p>
            <p>1、流量/话费/耳机等奖品将在活动结束后10个工作日内送达，如果届时未收到奖品，请在5月5日前联系爱音乐在线客服，逾期将默认放弃领奖；</p>
            <p>2、通过活动页面获得订购钻石会员将先从您手机账户中扣取10元，活动结束后将10元话费返回到手机账户中。如不取消订购，将默认继续订购该业务。</p>
            <p>3、院线通10元抵用券的使用规则，可关注［天翼爱音乐］公众号，回复“兑换码”查看。具体规则如下：本院线通抵用券可在购买电影时抵扣相应的金额，请在2016年5月31日前使用；具体使用可通过院线通客户端或登录d.189mv.cn进行兑换，进入院线通-活动-优惠码兑换，输入优惠码，即可兑换电影抵用券；兑换成功后可在院线通账户中查询。</p>
            <p>4、本活动最终解释权归天翼爱音乐所有。</p>
        </span>
    </div>
</div>
</body>
</html>